<template>
    <view>
        <!-- <view class="banner" @click="goDetail(banner)">
            <image class="banner-img" :src="banner.cover"></image>
            <view class="banner-title">{{banner.title}}</view>
        </view> -->
        <view class="uni-list">
            <view class="uni-list-cell" hover-class="uni-list-cell-hover" v-for="(value,key) in listData" :key="key"
                @click="goDetail(value)">
                <view class="uni-media-list">
                    <!-- <image class="uni-media-list-logo" :src="value.cover"></image> -->
                    <view class="uni-media-list-body">
                        <view class="uni-media-list-text-top">{{value.noticeTitle}}</view>
                        <view class="uni-media-list-text-bottom">
                            <text>{{value.updateBy}}</text>
                            <text>{{value.updateTime}}</text>
                        </view>
                    </view>
                </view>
            </view>
        </view>
    </view>
</template>

<script>
    var dateUtils = require('../../common/util.js').dateUtils;

    export default {
        data() {
            return {
                listData: [
					{
						title:"内容",
						author_name:"作者",
						published_at:"时间"
					},
					{
						title:"内容",
						author_name:"作者",
						published_at:"时间"
					}
				]
            }
        },
		onShow(){
			this.checkToken();
		},
        onLoad() {
            
        },
        onPullDownRefresh() {
           
        },
        onReachBottom() {
            
        },
        methods: {
            goDetail:function(e) {
				uni.navigateTo({
					url:'msgDetail?noticeId='+e.noticeId
				})
			},
			checkToken() //查用户信息
			{
				var that=this;
				 uni.getStorage({
				    key: 'token',
				    success: function (res) {
						
						that.getNotice(res.data);
				    },
					fail:function(error){
						uni.navigateTo({
							url: `/pages/login/login`
						})
					}});
			},
			//获取首页通知
			getNotice(token){
				var that=this;
				uni.request({
						url: that.serverUrl + '/core/api/v1/common/notice',
						method: "GET",
						header: {
							'content-type': 'application/json',
							'Authorization': 'Bearer '+token
						},
						success: (res) => {
							if (res.data.code == 200) {
								that.listData=res.data.data;
								console.log(that.listData);
							}
						},
						fail: (error) => {
							//console.log(error);
						}
					})
			},
			
        }
    }
</script>

<style lang="scss" scoped>
    .banner {
        height: 360upx;
        overflow: hidden;
        position: relative;
        background-color: #ccc;
    }

    .banner-img {
        width: 100%;
    }

    .banner-title {
        max-height: 84upx;
        overflow: hidden;
        position: absolute;
        left: 30upx;
        bottom: 30upx;
        width: 90%;
        font-size: 32upx;
        font-weight: 400;
        line-height: 42upx;
        color: white;
        z-index: 11;
    }

    .uni-list {
        background-color: #FFFFFF;
        position: relative;
        width: 100%;
        display: flex;
        flex-direction: column;
    }

    .uni-list:after {
        position: absolute;
        z-index: 10;
        right: 0;
        bottom: 0;
        left: 0;
        height: 1px;
        content: '';
        -webkit-transform: scaleY(.5);
        transform: scaleY(.5);
        background-color: #c8c7cc;
    }

    .uni-list::before {
        position: absolute;
        z-index: 10;
        right: 0;
        top: 0;
        left: 0;
        height: 1px;
        content: '';
        -webkit-transform: scaleY(.5);
        transform: scaleY(.5);
        background-color: #c8c7cc;
    }

    .uni-list-cell {
        position: relative;
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .uni-list-cell-hover {
        background-color: #eee;
    }

    .uni-list-cell::after {
        position: absolute;
        z-index: 3;
        right: 0;
        bottom: 0;
        left: 30upx;
        height: 1px;
        content: '';
        -webkit-transform: scaleY(.5);
        transform: scaleY(.5);
        background-color: #c8c7cc;
    }

    .uni-list .uni-list-cell:last-child::after {
        height: 0upx;
    }

    /* 图文列表 */
    .uni-media-list {
        padding: 22upx 30upx;
        box-sizing: border-box;
        display: flex;
        width: 100%;
        flex-direction: row;
    }

    .uni-navigate-right.uni-media-list {
        padding-right: 74upx;
    }

    .uni-pull-right {
        flex-direction: row-reverse;
    }

    .uni-pull-right>.uni-media-list-logo {
        margin-right: 0upx;
        margin-left: 20upx;
    }

    .uni-media-list-logo image {
        height: 100%;
        width: 100%;
    }


    .uni-media-list-text-bottom {
        width: 100%;
        line-height: 30upx;
        font-size: 26upx;
        color: #8f8f94;
    }

    .uni-media-list-logo {
        width: 180upx;
        height: 140upx;
        margin-right: 20upx;
    }

    .uni-media-list-body {
        display: flex;
        flex: 1;
        flex-direction: column;
        justify-content: space-between;
        align-items: flex-start;
        overflow: hidden;
        height: auto;
    }

    .uni-media-list-text-top {
        width: 100%;
        line-height: 36upx;
        font-size: 30upx;
        height: 74upx;
        font-size: 28upx;
        overflow: hidden;
    }

    .uni-media-list-text-bottom {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
    }
</style>
